/*
 * @file iso9660_charset.c
 *
 *    ISO9660 charset management
 */


#if HAVE_CONFIG_H
#include "config.h"
#endif

#include <stdarg.h>
#include <stdio.h>
#include <errno.h>
#include <iconv.h>
#include <string.h>
#include <rtems/seterr.h>

#include "iso9660_charset.h"

int
iso9660_charset_from_iocharset
(

    const char              *src,
    size_t                    src_size,
    char                    **dst,
    size_t                   *dst_size,
    const char              *dst_charset,
    const iso9660_fs_info_t *fs
)
{
  *dst = malloc(src_size * sizeof(char) + 1);
  if (*dst == NULL)
    rtems_iso9660_error_and_return_minus_one(ENOMEM,
        "from_iocharset: not enough memory");

  memcpy(*dst, src, src_size);
  *dst_size = src_size;

  return 0;
}

int
iso9660_charset_to_iocharset
(
    const char  *src,
    size_t        src_size,
    char        **dst,
    size_t       *dst_size,
    const char  *src_charset,
    const iso9660_fs_info_t *fs
)
{
  *dst = malloc(src_size * sizeof(char) + 1);
  if (*dst == NULL)
    rtems_iso9660_error_and_return_minus_one(ENOMEM,
        "to_iocharset: not enough memory");

  memcpy(*dst, src, src_size);
  *dst_size = src_size;

  return 0;
}
